function showSupplierInfo(sid){
    (new AjaxRequest).send({
		url			: urlBase+"action=getSupplier",
		data		: {
			id : sid
		},
		
		onSuccess	: function(data, info)
		{
            hide('confirm');
            unhide('addGroupForm',true);
            
            document.getElementById('addGroupName').value = data.supplier.name;
            document.getElementById('addGroupAdr1').value = data.supplier.adr1;
            document.getElementById('addGroupAdr2').value = data.supplier.adr2;
            document.getElementById('addGroupCity').value = data.supplier.city;
            document.getElementById('addGroupCountry').value = data.supplier.country;
            document.getElementById('addGroupZIP').value = data.supplier.zip;
            document.getElementById('addGroupTel').value = data.supplier.tel;
            document.getElementById('addGroupFax').value = data.supplier.fax;
            document.getElementById('addGroupMail').value = data.supplier.mail;  
            document.getElementById('addGroupID').value = data.supplier.id;    
            document.getElementById('addGroupNotes').value = data.supplier.notes;    
            
            mySelect = document.getElementById('addGroupNotification');
            for(var i=0; i < mySelect.options.length; i++){
                if(mySelect.options[i].value == data.supplier.notification){
                    mySelect.selectedIndex = i;
                    break;
                }
            }

            document.getElementById('sSubmit').value = 'Update Supplier';
            
            
            document.getElementById('1pname').value = data.supplier.p1name; 
            document.getElementById('1ppos').value = data.supplier.p1pos; 
            document.getElementById('1pnotes').value = data.supplier.p1notes; 
            
            document.getElementById('2pname').value = data.supplier.p2name; 
            document.getElementById('2ppos').value = data.supplier.p2pos; 
            document.getElementById('2pnotes').value = data.supplier.p2notes; 
            
            document.getElementById('3pname').value = data.supplier.p3name; 
            document.getElementById('3ppos').value = data.supplier.p3pos; 
            document.getElementById('3pnotes').value = data.supplier.p3notes; 
		}
	});
}

function clearSForm(){
    document.getElementById('addGroupName').value = '';
    document.getElementById('addGroupName').className = 'textInput';
    document.getElementById('addGroupAdr1').value = '';
    document.getElementById('addGroupAdr2').value = '';
    document.getElementById('addGroupCity').value = '';
    document.getElementById('addGroupCountry').value = '';
    document.getElementById('addGroupZIP').value = '';
    document.getElementById('addGroupTel').value = '';
    document.getElementById('addGroupFax').value = '';
    document.getElementById('addGroupMail').value = '';    
    document.getElementById('addGroupMail').className = 'textInput';
    document.getElementById('addGroupNotification').selectedIndex = 0;
    document.getElementById('addGroupID').value = '';    
    document.getElementById('addGroupNotes').value = ''; 
    document.getElementById('sSubmit').value = 'Add Supplier';
    
    document.getElementById('1pname').value = ''; 
    document.getElementById('1ppos').value = ''; 
    document.getElementById('1pnotes').value = ''; 
    
    document.getElementById('2pname').value = ''; 
    document.getElementById('2ppos').value = ''; 
    document.getElementById('2pnotes').value = ''; 
    
    document.getElementById('3pname').value = ''; 
    document.getElementById('3ppos').value = ''; 
    document.getElementById('3pnotes').value = ''; 
}

function deleteSupplier(sid){
    if(confirm('Really Delete Supplier?')){
        deleteme('group_'+sid);
        
        (new AjaxRequest).send({
            url			: urlBase+"action=deleteSupplier",
            data		: {
                id : sid
            },
            
            onSuccess	: function(data, info)
            {
                hide('confirm');
                clearSForm();                
                deleteRow('group_'+sid);
            }
        });
    }
}